CSCI E-92: Application Note 16 Notes on Using Serial Port I/O through a UART --------------------------------------------- Configuring the serial port: o In SecureCRT, setting the Port name, the serial communication Baud rate (i.e., the number of bits per second), the number of Data bits, whether Parity is enabled, the number of Stop bits, and whether Flow control is enabled, are accomplished in "Connection -> Serial." These should be set as follows: Port as reported by the host OS, Baud rate as configured in the K70, Data bits to 8, Parity to None, Stop bits to 1, all Flow control (DTR/DSR, RTS/CTS, XON/XOFF) *not* checked. o In PuTTY, setting the Port name, the serial communication Baud rate (i.e., the number of bits per second), the number of Data bits, whether Parity is enabled, the number of Stop bits, and whether Flow control is enabled, are accomplished in "Connection -> Serial." These should be set as follows: Serial line to connect to as reported by the host OS, Speed (baud) as configured in the K70, Data bits to 8, Stop bits to 1, Parity to None, Flow control to None. Line termination character handling: o In a string constant in C, the \n (new-line) escape character is mapped to a line-feed (0x0a) character. o In a string constant in C, the \r (carriage-return) escape character is mapped to a carriage-return (0x0d) character. o Input of the Enter key: When the Enter key is pressed in a terminal emulation program, a carriage-return (0x0d) is sent to the UART. On old keyboards, this key was originally labeled as "return." Input echoing: o By default, characters typed in a terminal emulation program are *not* displayed. The OS you are developing will be responsible for echoing each character back to the terminal emulation program if you want it to be displayed. This allows some input to be displayed and other to not be displayed (for example, when a password is typed). If you decide to implement serial port attributes in your OS, then you could have a serial port attribute in your OS that would determine whether input characters are echoed back to the source. A mode that displays all characters when typed is referred to as "local echo". o In SecureCRT, local echo is controlled under Terminal -> Emulation -> Advanced, do *not* check "Local echo." o In PuTTY: local echo is controlled under Terminal in the "Line discipline options" section. For"Local echo:" select "Force off." Handling of carriage-return and line-feed characters: o Output of carriage-return: When a carriage-return (0x0d) is output to a terminal emulation program, the cursor moves to the beginning of the current line (but does not move to the next line). o Output of line-feed: When a line-feed (0x0a) is output to a terminal emulation program, the cursor moves to the same position on the next line (but does not move to the beginning of the line). o Output to go to the beginning of the next line: In your OS, you should explicitly first send a carriage-return then a line-feed to go to the beginning of the next line. If you decide to implement serial port attributes in your OS, then you could have a serial port attribute in your OS that would determine whether outputting a line-feed (new-line) would actually output a carriage-return followed by a line-feed or just a line-feed. o In SecureCRT, set Carriage-return and line-feed behavior as follows. Do *not* turn on "Translate incoming CR to CR/LF" mode under Terminal -> Emulation -> Advanced. This would affect how CR is displayed when received by the terminal emulation program. "Translate incoming CR to CR/LF" would display both a CR and LF whenever a CR was received by SecureCRT. o In PuTTY, set Carriage-return and line-feed behavior as follows. Do *not* check "Implicit CR in every LF". Do *not* check "Implicit LF in every CR". These modes would affect how characters are displayed when received by the terminal emulation program. "Implicit CR in every LF" would display both a CR and LF whenever an LF was received by PuTTY. "Implicit LF in every CR" would display both a CR and LF whenever a CR was received by PuTTY. These options are found in PuTTY under Terminal. Handling of BS (backspace) and DEL (delete) characters: o In SecureCRT, set the behavior for typing a backspace (BS) or delete (DEL) as follows. As expected (and by default), when connected to a serial port, SecureCRT will send a backspace (BS) character (0x08) when the backspace key is typed and will send a delete (DEL) character (0x7f) when the delete key is typed. See the SecureCRT "Options -> Session Options" "Terminal -> Emulation -> Mapped Keys" to change this behavior. o In PuTTY, set the behavior for typing a backspace (BS) as follows. By default, when connected to a serial port, PuTTY will send a delete (DEL) character (Control-?, 0x7f, 127) when the backspace key is typed rather than sending the backspace character (0x08). You should modify the character sent by typing the backspace key from "Control-? (127)" to "Control-H." The option to change this behavior is under Terminal -> Keyboard. Typing shift-backspace will cause PuTTY to send whichever code isn't configured as the default. PuTTY should send a delete (DEL) whenever the delete key is typed. o In PuTTY, set the behavior on *receiving* a delete (DEL) as follows. Normally, when PuTTY receives a delete (DEL) character (0x7f) to be displayed, it will perform a "destructive backspace" (i.e., it will move the cursor one space left and delete the character under it). See the PuTTY "Terminal -> Features" to configure the delete (DEL) character to perform a normal backspace (without deleting a character) instead by checking "Disable destructive backspace on server sending ^?," if desired.